var app = getApp()

Page({
  data: {
    maidian: 0,
    balance: 0,
    couponCount: 0,
    userRoleTitle: '普通会员'
  },
  onLoad: function () {
    //app.showLoading()
  },
  onShow: function () {
    app.ready(() => {
      app.getUserInfo().then(() => {
        //app.hideLoading()
        this.hideLoading()
        this.setData({
          balance: app.globalData.balance,
          couponCount: app.globalData.couponCount
        })
      })
      app.getVipInfo().then(res => {
        this.setData({
          maidian: res.bonusPoint,
          userRoleTitle: res.userTitle
        })
      })
    })
    app.error(err => {
      app.toast.error(err)
    })
  },
  hideLoading: function () {
    this.selectComponent('#spin').hide()
  },
  ucAction: function (event) {
    var actiontype = event.currentTarget.dataset.actiontype
    if (actiontype === 'order') {
      wx.navigateTo({
        url: './order/order'
      })
    }
    else if (actiontype === 'address') {
      wx.navigateTo({
        url: './address/address'
      })
    }
    else if (actiontype === 'person') {
      wx.navigateTo({
        url: './editinfo/editinfo'
      })
    }
    else if (actiontype === 'vip') {
      wx.navigateTo({
        url: './vip/vip'
      })
    }
    else if (actiontype === 'card') {
      wx.navigateTo({
        url: './card/card'
      })
    }
    else if (actiontype === 'shop') {
      wx.navigateTo({
        url: './stores/stores?target=store'
      })
    }
  },
  maidianDetail: function () {
    wx.navigateTo({
      url: './mddetail/mddetail'
    })
  },
  contactClient: function () {
    wx.makePhoneCall({
      phoneNumber: '400-992-6632'
    })
  },
  suggestReturn: function () {
    wx.navigateTo({
      url: './suggest/suggest'
    })
  },
  memoryDays: function () {
    wx.navigateTo({
      url: './days/days'
    })
  },
  balanceDeal: function () {
    wx.navigateTo({
      url: './balance/balance'
    })
  },
  couponDetail: function () {
    wx.navigateTo({
      url: './coupon/couponindex'
    })
  },
  normalQA: function () {
    wx.navigateTo({
      url: './stores/stores?target=qa'
    })
  },
  freePay: function () {
    wx.navigateTo({
      url: './freepay/freepay'
    })
  }
})
